package lancooControl;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;

import com.example.hyznbk.R;


/**
 * 保存试题答案
 * Created by Administrator on 2016/10/17.
 */
public class BackPreservationDialog extends Dialog {

    private Context context;
    private ClickListenerInterface clickListenerInterface;
    public static Button BtnContinueAnswer;
    public static Button BtnConfirmAnswer;



    public interface ClickListenerInterface {
        public void doContinueAnswer();
        public void doConfirmAnswer();
    }

    public BackPreservationDialog(Context context) {
        super(context, R.style.CustomDialog);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        init();

        getWindow().setBackgroundDrawableResource(R.color.vifrification);
    }

    public void init() {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.dialog_back_preservation, null);
        setContentView(view);

        BtnContinueAnswer = (Button) findViewById(R.id.button_continue_answer);
        BtnContinueAnswer.setOnClickListener(new clickListener());

        BtnConfirmAnswer = (Button) findViewById(R.id.button_confirm_answer);
        BtnConfirmAnswer.setOnClickListener(new clickListener());

        setCanceledOnTouchOutside(false);

    }

    public void setClicklistener(ClickListenerInterface clickListenerInterface) {
        this.clickListenerInterface = clickListenerInterface;
    }


    private class clickListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            int id = v.getId();
            switch (id) {
                case R.id.button_continue_answer://继续作答
                    System.out.println("------long-------cancle cancle  cancle----------------");
                    clickListenerInterface.doContinueAnswer();
                    break;

                case R.id.button_confirm_answer://退出作答
                    clickListenerInterface.doConfirmAnswer();
                    break;

                default:
                    System.out.println("-----ooooooo11111defalt----------------");
                    break;
            }
        }

    };

}